#pragma once

#include <QObject>
#include <qsqldatabase.h>
#include <qsqltablemodel.h>

class UseMySql : public QObject
{
	Q_OBJECT

public:
	UseMySql(QObject *parent =  nullptr);
	~UseMySql();

public:
	static UseMySql* instance();

	QSqlTableModel* getTableModel(QObject* parent,const QString& tableName);

	void addProject(QString name, QString path, QString desc);

	QString getProjectPathFromID(int id);
	QString getProjectNameFromID(int id);
	QString getModifiedDateFromID(int id);

	int getMaxProjectID();

	void insertIntoTabProjectInfo(QStringList& list);

private:
	bool connectMySql();

private:
	QSqlDatabase dbase;

};

